package com.dsz.day5set;

public class BinaryTreeDFS {

    public  static  void dfs(TreeNode node){
        if (node == null){
            return;
        }
        System.out.println(node.val + "");

        dfs(node.left);
        dfs(node.right);

    }

    //创建二叉树，并执行深度优先搜索遍历
    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(3);
        root.left.left = new TreeNode(4);
        root.left.right = new TreeNode(5);
        root.right.left = new TreeNode(6);
        root.right.right = new TreeNode(7);
        dfs(root);
    }

}
//最后输出1245367